import { AES, enc } from 'crypto-js'
const KEY_AES = 'lkfdjslfjldsjlfdsfjlds'

export default {
    state: {
        token: '',
        userInfo: {},
        menuList: [],
        menuActive:'/home',
        userEole:{}
    },
    getters: {
        // token(state) {
        //     return state.token
        // }
        token: ({ token }) => AES.decrypt(token, KEY_AES).toString(enc.Utf8),
        menuList: ({ menuList }) => menuList,
        menuActive: ({ menuActive }) => menuActive,
        userEole: ({ userEole }) => userEole,
        userInfo: ({ userInfo }) => userInfo,
    },
    mutations: {
        mutationToken(state, _token) {
            state.token = AES.encrypt(_token, KEY_AES).toString()
        },
        mutationMenuList(state, _menuList) {
            state.menuList = _menuList
        },
        mutationUserInfo(state, _userInfo) {
            state.userInfo = _userInfo
        },
        mutationmenuActive(state, _menuActive) {
            state.menuActive = _menuActive
        },
        mutationuserEole(state, _userEole) {
            state.userEole = _userEole
        }
    }
}